Feat/게이트웨이 모니터링용 엔드포인트 노출#6
Hidden character warning
Conversation
There was a problem hiding this comment.
Pull request overview
이 PR은 핀잇 API 게이트웨이에 Prometheus 기반 모니터링을 위한 Actuator 엔드포인트를 추가합니다.
- Spring Boot Actuator 엔드포인트(health, info, metrics, prometheus) 노출 설정 추가
- Prometheus 레지스트리 의존성 추가
- 모니터링 접근을 위한 새로운 도메인(gateway.pinit.go-gradually.me) Ingress 규칙 추가
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/main/resources/application-prod.yml | Gateway 메트릭 활성화 및 management 엔드포인트 노출 설정 추가 |
| k8s/ingress.yaml | 모니터링용 gateway.pinit.go-gradually.me 도메인에 대한 Ingress 규칙 추가 |
| build.gradle | Prometheus 메트릭 수집을 위한 micrometer-registry-prometheus 의존성 추가 |
| management: | ||
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: "health,info,metrics,prometheus" |
There was a problem hiding this comment.
문제점: /actuator/metrics와 /actuator/prometheus 엔드포인트가 인증 없이 노출되어 있습니다. SecurityConfig에서 /actuator/health/liveness와 /actuator/health/readiness만 허용하도록 설정되어 있지만, 새로 추가된 metrics와 prometheus 엔드포인트는 인증이 필요한 상태로 남아있습니다.
영향: 현재 설정으로는 모니터링 시스템(예: Prometheus)이 메트릭을 수집할 때 JWT 인증이 필요하여 정상적으로 메트릭 수집이 불가능합니다.
수정 제안: SecurityConfig.java의 mainSecurityFilterChain 메서드에서 /actuator/metrics/**와 /actuator/prometheus를 permitAll() 목록에 추가해야 합니다.
k8s/ingress.yaml
Outdated
| - host: gateway.pinit.go-gradually.me | ||
| http: | ||
| paths: | ||
| - path: / | ||
| pathType: Prefix | ||
| backend: | ||
| service: | ||
| name: gateway-service | ||
| port: | ||
| number: 80 No newline at end of file |
There was a problem hiding this comment.
문제점: TLS 설정의 hosts 목록에 새로 추가된 gateway.pinit.go-gradually.me 도메인이 포함되지 않았습니다.
영향: gateway.pinit.go-gradually.me로 접속 시 TLS/HTTPS 인증서가 적용되지 않아 보안 경고가 발생하거나 접속이 차단될 수 있습니다.
수정 제안: spec.tls[0].hosts 배열에 gateway.pinit.go-gradually.me를 추가해야 합니다.
k8s/ingress.yaml
Outdated
| - host: gateway.pinit.go-gradually.me | ||
| http: | ||
| paths: | ||
| - path: / |
There was a problem hiding this comment.
문제점: gateway.pinit.go-gradually.me를 통해 모든 경로(/)에 대한 접근이 허용되어 있습니다. 이는 모니터링 목적의 엔드포인트뿐만 아니라 다른 모든 서비스 경로도 이 도메인으로 접근 가능하다는 의미입니다.
영향: 의도하지 않은 보안 노출이 발생할 수 있으며, 모니터링 전용 도메인의 목적이 불명확해집니다.
수정 제안: path를 /actuator/**로 제한하여 모니터링 엔드포인트만 노출되도록 해야 합니다.
| management: | ||
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: "health,info,metrics,prometheus" |
There was a problem hiding this comment.
문제점: 메트릭 수집 설정이 production 환경에만 추가되어 있고, development 환경(application-dev.yml)에는 누락되어 있습니다.
영향: 개발 환경에서 모니터링 기능을 테스트하거나 검증할 수 없어, production 배포 전 충분한 검증이 어렵습니다.
수정 제안: application-dev.yml에도 동일한 management 엔드포인트 설정을 추가하여 일관성을 유지하고 개발 단계에서도 모니터링을 테스트할 수 있도록 해야 합니다.
| metrics: | ||
| enabled: true |
There was a problem hiding this comment.
문제점: spring.cloud.gateway.server.webflux.metrics.enabled 설정의 위치가 올바르지 않습니다. 이 설정은 spring.cloud.gateway.metrics.enabled로 설정되어야 합니다.
영향: 현재 경로에서는 Gateway의 메트릭이 제대로 활성화되지 않을 수 있으며, Spring Cloud Gateway의 공식 설정 경로와 일치하지 않습니다.
수정 제안: 설정 경로를 spring.cloud.gateway.metrics.enabled: true로 수정해야 합니다.
| port: 9095 | ||
| targetPort: 9095 |
There was a problem hiding this comment.
문제점: 관리 엔드포인트가 별도의 포트(9095)에서 실행되도록 설정되었지만, Kubernetes Deployment에 해당 포트가 노출되지 않았습니다.
영향: Kubernetes 환경에서 메트릭 서비스(gateway-metrics-service)가 포트 9095로 트래픽을 전달하려고 하지만, 컨테이너가 해당 포트를 노출하지 않아 연결이 실패합니다.
수정 제안: k8s/deployment.yaml의 ports 섹션에 관리 포트를 추가해야 합니다. containerPort: 9095를 name: management로 추가하세요.
| return applyCommon(http) | ||
| .authorizeExchange(auth -> auth | ||
| .pathMatchers("/actuator/health/liveness", "/actuator/health/readiness", "/v3/**", "/swagger-ui/**", "/async-api/**").permitAll() | ||
| .pathMatchers("/actuator/prometheus", "/actuator/health/liveness", "/actuator/health/readiness", "/v3/**", "/swagger-ui/**", "/async-api/**").permitAll() |
There was a problem hiding this comment.
문제점: /actuator/prometheus 엔드포인트가 주 게이트웨이 포트(8080)에서 인증 없이 접근 가능하도록 설정되어 있습니다. 하지만 management.server.port 설정에 따라 actuator 엔드포인트는 별도 포트(9095)에서만 접근 가능하므로 이 설정이 의도대로 작동하지 않습니다.
영향: 보안 설정이 불필요하거나 혼란을 야기할 수 있으며, 실제로 prometheus 엔드포인트는 9095 포트를 통해서만 접근 가능하므로 8080 포트의 보안 설정은 효과가 없습니다.
수정 제안: management.server.port를 사용하는 경우 actuator 엔드포인트는 별도 포트에서만 노출되므로, 주 포트의 보안 설정에서 /actuator/prometheus를 제거하는 것이 명확합니다. 또는 별도 관리 포트용 보안 설정을 추가로 구성해야 합니다.
| - protocol: TCP | ||
| port: 9095 | ||
| targetPort: 9095 | ||
| type: NodePort |
There was a problem hiding this comment.
문제점: NodePort 타입의 서비스는 클러스터 외부에서 직접 접근이 가능하므로, 민감한 메트릭 정보가 노출될 수 있는 보안 위험이 있습니다.
영향: 인증 없이 외부에서 애플리케이션 메트릭에 접근할 수 있어, 시스템 내부 정보 노출, 성능 분석을 통한 공격 벡터 파악 등의 보안 위험이 존재합니다.
수정 제안: 프로메테우스가 클러스터 내부에서 실행되는 경우 type을 ClusterIP로 변경하거나, 외부 접근이 필요한 경우 인증/인가 메커니즘(예: NetworkPolicy, Ingress with authentication)을 추가해야 합니다.
| type: NodePort | |
| type: ClusterIP |
| metrics: | ||
| enabled: true |
There was a problem hiding this comment.
문제점: Spring Cloud Gateway의 메트릭 설정이 routes 섹션 내부의 잘못된 위치에 있습니다. metrics 설정은 spring.cloud.gateway 레벨에 있어야 하며, routes 섹션 안에 있으면 안 됩니다.
영향: 설정이 제대로 인식되지 않아 게이트웨이 메트릭이 수집되지 않을 수 있습니다.
수정 제안: metrics 설정을 spring.cloud.gateway 레벨로 이동시켜야 합니다. 현재 spring.cloud.gateway.server.webflux.routes 내부가 아닌 spring.cloud.gateway 바로 아래에 위치해야 합니다.
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: "health,info,metrics,prometheus" |
There was a problem hiding this comment.
문제점: management 엔드포인트에 노출된 "info", "metrics" 엔드포인트가 민감한 정보를 포함할 수 있습니다.
영향: 애플리케이션의 내부 구성, 종속성 버전, 런타임 메트릭 등의 정보가 노출되어 공격자가 시스템 분석 및 취약점 파악에 활용할 수 있습니다.
수정 제안: 모니터링 목적이라면 "prometheus" 엔드포인트만 노출하고 나머지는 제거하거나, 별도의 인증 메커니즘을 추가하는 것을 고려해야 합니다.
| include: "health,info,metrics,prometheus" | |
| include: "health,prometheus" |
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: "health,info,metrics,prometheus" |
There was a problem hiding this comment.
문제점: management 엔드포인트에 노출된 "info", "metrics" 엔드포인트가 민감한 정보를 포함할 수 있습니다.
영향: 애플리케이션의 내부 구성, 종속성 버전, 런타임 메트릭 등의 정보가 노출되어 공격자가 시스템 분석 및 취약점 파악에 활용할 수 있습니다.
수정 제안: 모니터링 목적이라면 "prometheus" 엔드포인트만 노출하고 나머지는 제거하거나, 별도의 인증 메커니즘을 추가하는 것을 고려해야 합니다.
| include: "health,info,metrics,prometheus" | |
| include: "prometheus" |
변경된 점